
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class TmsStoreServiceImpl implements TmsStoreService  {

    @Resource
    private TmsStoreMapper tmsStoreMapper;

    /**
     * 获取 TmsStore 分页列表
     */
    @Transactional
    public IPage getTmsStorePagination( PaginationVo paginationVo, TmsStoreQuery tmsStoreQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<TmsStoreEntity> lqs = new LambdaQueryWrapper();
        tmsStoreMapper.selectPage(page, lqs);

        List<TmsStoreEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 TmsStore 所有数据
     *
    */
    @Transactional
    public List<TmsStoreEntity> getTmsStoreAllList( TmsStoreQuery tmsStoreQuery ) throws Exception {

        LambdaQueryWrapper<TmsStoreEntity> lqs = new LambdaQueryWrapper();
        List<TmsStoreEntity> list = tmsStoreMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 TmsStore 详情
    */
    @Transactional
    public TmsStoreEntity getTmsStoreDetail( Long id) throws Exception {

        TmsStoreEntity tmsStore = tmsStoreMapper.selectById(id);
        return tmsStore;
    }


    /**
     * 新增 TmsStore
     * */
    @Transactional
    public void addTmsStore(TmsStoreVo tmsStoreVo) throws Exception {

        TmsStoreEntity tmsStore = new TmsStoreEntity();
        ReflectionCopy.copyProperties( tmsStore, tmsStoreVo );
        tmsStoreMapper.insert(tmsStore);
        return;
    }


    /**
     * 更新 TmsStore
     * */
    @Transactional
    public void updateTmsStore( TmsStoreVo tmsStoreVo) throws Exception {

        if( tmsStoreVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        TmsStoreEntity tmsStore = new TmsStoreEntity();
        ReflectionCopy.copyProperties( tmsStore, tmsStoreVo );
        tmsStoreMapper.updateById(tmsStore);
        return;
    }

    /**
     * 删除 TmsStore
     * */
    @Transactional
    public void batchRemoveTmsStore( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        tmsStoreMapper.deleteBatchIds(ids);
    }

}

      